package com.centaline.androidsalesblog.base;

import android.os.Bundle;
import android.text.TextUtils;

import com.android.volley.VolleyError;
import com.baidu.location.BDLocation;
import com.baidu.mapapi.map.MapStatus;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.Marker;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.model.LatLngBounds;
import com.baidu.mapapi.search.busline.BusLineResult;
import com.baidu.mapapi.search.busline.BusLineSearch;
import com.baidu.mapapi.search.busline.BusLineSearchOption;
import com.baidu.mapapi.search.busline.OnGetBusLineSearchResultListener;
import com.baidu.mapapi.search.core.PoiInfo;
import com.baidu.mapapi.search.core.SearchResult;
import com.baidu.mapapi.search.poi.OnGetPoiSearchResultListener;
import com.baidu.mapapi.search.poi.PoiCitySearchOption;
import com.baidu.mapapi.search.poi.PoiDetailResult;
import com.baidu.mapapi.search.poi.PoiResult;
import com.baidu.mapapi.search.poi.PoiSearch;
import com.centaline.androidsalesblog.api.sale.EsfMapApi;
import com.centaline.androidsalesblog.api.sale.PostListApi;
import com.centaline.androidsalesblog.api.sale.RegionPosts3Api;
import com.centaline.androidsalesblog.constants.AppConstant;
import com.centaline.androidsalesblog.constants.ExtraConstant;
import com.centaline.androidsalesblog.iml.BaiduMarkerClick;
import com.centaline.androidsalesblog.iml.DropCompleteListener;
import com.centaline.androidsalesblog.iml.PostMapCallback;
import com.centaline.androidsalesblog.model.businissobject.DropBo;
import com.centaline.androidsalesblog.model.businissobject.RegionPostBo;
import com.centaline.androidsalesblog.model.businissobject.SaleMainMapBo;
import com.centaline.androidsalesblog.model.databaseobject.EsfEstateDo;
import com.centaline.androidsalesblog.model.responseobject.EsfEstateListRo;
import com.centaline.androidsalesblog.model.responseobject.PostListRo;
import com.centaline.androidsalesblog.model.responseobject.RegionPostRo;
import com.centaline.androidsalesblog.overlay.RailwayLineOverlay;
import com.centaline.androidsalesblog.overlay.local.EsfMainMapOverlay;
import com.centaline.androidsalesblog.overlay.local.SaleRegionLevelOverlay;
import com.centaline.androidsalesblog.utils.DropUtil;
import com.centanet.framework.interfaces.IResponseListener;

import java.util.ArrayList;

/**
 * 地体找房-租售基类
 * Created by guilin on 16/4/14.
 */
public abstract class PostMainMapFragment extends BaseMainMapFragment {

    protected SaleRegionLevelOverlay saleRegionLevelOverlay;
    protected EsfMainMapOverlay esfMainMapOverlay;
    protected RailwayLineOverlay railwayLineOverlay;

    protected ArrayList<RegionPostBo> mapShowList = new ArrayList<>();//地图显示数据
    protected ArrayList<RegionPostBo> regionList = new ArrayList<>();//区域数据
    protected ArrayList<RegionPostBo> gscopList = new ArrayList<>();//板块数据
    protected ArrayList<EsfEstateDo> esfEstateDos = new ArrayList<>();

    protected MapStatus endMapStatus;

    protected PostListApi postListApi;
    protected RegionPosts3Api regionPosts3Api;
    protected EsfMapApi esfMapApi;

    protected SaleMainMapBo saleMainMapBo;

    protected PoiSearch poiSearch;
    protected BusLineSearch busLineSearch;
    protected String stationName;//站点名字
    protected int targetScreenY;//中心点
    protected int detailStatus;//详情状态0:打开;1:关闭
    protected String tempRegionId;

    protected PostMapCallback<EsfEstateDo> postMapCallback;

    public void setPostMapCallback(PostMapCallback<EsfEstateDo> postMapCallback) {
        this.postMapCallback = postMapCallback;
    }

    @Override
    protected DropCompleteListener getDropCompleteListener() {
        dropCompleteListener = new DropCompleteListener() {
            @Override
            public void complete(int position, boolean fromMore, int type, DropBo... dropBos) {
                final int size = dropBos == null ? 0 : dropBos.length;
                switch (type) {
                    case 10://区域
                        mapStatusChangeTag = -1;
                        railwayLineOverlay.removeFromMap();
                        if (size == 1) {
                            if (DropUtil.compareValue(dropBos[0])) {
                                resetTab(position);
                                setTab(position, "区域");
                                baiduMap.animateMapStatus(MapStatusUpdateFactory.zoomTo(12f));
                            } else {
                                setTab(position, dropBos[0].getText());
                                for (RegionPostBo regionPostBo : regionList) {
                                    if (dropBos[0].getValue().equals(String.valueOf(regionPostBo.getGScopeId()))) {
                                        tempRegionId = String.valueOf(regionPostBo.getGScopeId());
                                        baiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngZoom(
                                                new LatLng(regionPostBo.getLat(), regionPostBo.getLng()), 14f));
                                        break;
                                    }
                                }
                                baiduEvent("F1_3_Value", dropBos[0].getText());
                            }
                        } else if (size == 2) {
                            if (DropUtil.compareValue(dropBos[1])) {
                                setTab(position, dropBos[0].getText());
                                for (RegionPostBo regionPostBo : regionList) {
                                    if (dropBos[0].getValue().equals(String.valueOf(regionPostBo.getGScopeId()))) {
                                        tempRegionId = String.valueOf(regionPostBo.getGScopeId());
                                        baiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngZoom(
                                                new LatLng(regionPostBo.getLat(), regionPostBo.getLng()), 14f));
                                        break;
                                    }
                                }
                                baiduEvent("F1_3_Value", dropBos[0].getText());
                            } else {
                                setTab(position, dropBos[1].getText());
                                int count = 0;
                                for (RegionPostBo regionPostBo : gscopList) {
                                    if (dropBos[1].getValue().equals(String.valueOf(regionPostBo.getGScopeId()))) {
                                        count++;
                                        baiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngZoom(
                                                new LatLng(regionPostBo.getLat(), regionPostBo.getLng()), 17f));
                                        break;
                                    }
                                }
                                if (count == 0) {
                                    toast("未找到结果");
                                }
                                baiduEvent("F1_3_Value", dropBos[1].getText());
                            }
                        }
                        break;
                    case 11://附近
                        if (size == 2) {
                            startLocation();
                            if ("1000".equals(dropBos[1].getValue())) {
                                distance = 1000;
                            } else if ("1500".equals(dropBos[1].getValue())) {
                                distance = 1500;
                            } else {
                                distance = 2000;
                            }
                            setTab(position, dropBos[1].getText());
                            baiduEvent("F1_3_Value", dropBos[1].getText());
                        }
                        break;
                    case 20://地铁
                        mapStatusChangeTag = -1;
                        railwayLineOverlay.removeFromMap();
                        if (size == 1) {
                            if (DropUtil.compareValue(dropBos[0])) {
                                resetTab(position);
                                setTab(position, "地铁");
                                baiduMap.animateMapStatus(MapStatusUpdateFactory.zoomTo(12f));
                            } else {
                                setTab(position, dropBos[0].getText());
                                showLoadingDialog();
                                poiSearch.searchInCity(new PoiCitySearchOption()
                                        .city(AppConstant.CityName)
                                        .pageCapacity(20)
                                        .keyword(dropBos[0].getText()));
                                baiduEvent("F1_3_Value", dropBos[0].getText());
                            }
                        } else if (size == 2) {
                            if (DropUtil.compareValue(dropBos[1])) {
                                setTab(position, dropBos[0].getText());
                                showLoadingDialog();
                                poiSearch.searchInCity(new PoiCitySearchOption()
                                        .city(AppConstant.CityName)
                                        .pageCapacity(20)
                                        .keyword(dropBos[0].getText()));
                                baiduEvent("F1_3_Value", dropBos[0].getText());
                            } else {
                                setTab(position, dropBos[1].getText());
                                showLoadingDialog();
                                poiSearch.searchInCity(new PoiCitySearchOption()
                                        .city(AppConstant.CityName)
                                        .pageCapacity(20)
                                        .keyword(dropBos[0].getText()));
                                stationName = dropBos[1].getText();
                                baiduEvent("F1_3_Value", dropBos[1].getText());
                            }
                        }
                        break;
                    case 30://总价
                        regionPosts3Api.setPrice("0");
                        regionPosts3Api.setMinInputPrice("");
                        regionPosts3Api.setMaxInputPrice("");
                        esfMapApi.setPrice("0");
                        esfMapApi.setMinInputPrice("");
                        esfMapApi.setMaxInputPrice("");
                        postListApi.setPrice("");
                        postListApi.setMin("");
                        postListApi.setMax("");
                        if (size == 1) {
                            if (DropUtil.compareValue(dropBos[0])) {
                                resetTab(position);
                            } else {
                                regionPosts3Api.setPrice(dropBos[0].getValue());
                                esfMapApi.setPrice(dropBos[0].getValue());
                                postListApi.setPrice(dropBos[0].getValue());
                                setTab(position, dropBos[0].getText());
                            }
                            requestRegionList();
                            baiduEvent("F1_4_Value", dropBos[0].getText());
                        } else if (size == 2) {
                            regionPosts3Api.setMinInputPrice(dropBos[0].getValue());
                            regionPosts3Api.setMaxInputPrice(dropBos[1].getValue());
                            esfMapApi.setMinInputPrice(dropBos[0].getValue());
                            esfMapApi.setMaxInputPrice(dropBos[1].getValue());
                            postListApi.setMin(dropBos[0].getValue());
                            postListApi.setMax(dropBos[1].getValue());
                            setTab(position, DropUtil.customPrice(dropBos[0], dropBos[1]));
                            baiduEvent("F1_4_Value", DropUtil.customPrice(dropBos[0], dropBos[1]));
                        }
                        if (baiduMap.getMapStatus().zoom > 16f) {
                            esfMapApi.startRequest();
                        }
                        requestRegionList();
                        break;
                    case 40://房型
                        regionPosts3Api.setRoom("0");
                        esfMapApi.setRoom("0");
                        postListApi.setRoom("");
                        if (size == 0) {
                            resetTab(position);
                        } else {
                            regionPosts3Api.setRoom(dropBos[0].getValue());
                            esfMapApi.setRoom(dropBos[0].getValue());
                            postListApi.setRoom(dropBos[0].getValue());
                            if (DropUtil.compareValue(dropBos[0])) {
                                resetTab(position);
                            } else {
                                setTab(position, dropBos[0].getText());
                                baiduEvent("F1_5_Value", dropBos[0].getText());
                            }
                        }
                        if (baiduMap.getMapStatus().zoom > 16f) {
                            esfMapApi.startRequest();
                        }
                        requestRegionList();
                        break;
                    case 60://面积
                        regionPosts3Api.setArea("0");
                        esfMapApi.setArea("0");
                        postListApi.setArea("0");
                        if (size == 0) {
                            resetTab(position);
                        } else {
                            regionPosts3Api.setArea(dropBos[0].getValue());
                            esfMapApi.setArea(dropBos[0].getValue());
                            postListApi.setArea(dropBos[0].getValue());
                            setTab(position, dropBos[0].getText());
                        }
                        if (baiduMap.getMapStatus().zoom > 16f) {
                            esfMapApi.startRequest();
                        }
                        requestRegionList();
                        break;
                    default:
                        break;
                }
            }
        };
        return dropCompleteListener;
    }

    protected OnGetPoiSearchResultListener onGetPoiSearchResultListener = new
            OnGetPoiSearchResultListener() {
                @Override
                public void onGetPoiResult(PoiResult poiResult) {
                    if (poiResult == null ||
                            poiResult.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
                        cancelLoadingDialog();
                        toast("未找到结果");
                        return;
                    }
                    int count = 0;
                    if (poiResult.error == SearchResult.ERRORNO.NO_ERROR) {
                        for (PoiInfo poiInfo : poiResult.getAllPoi()) {
                            if (poiInfo.type == PoiInfo.POITYPE.SUBWAY_LINE) {
                                count++;
                                busLineSearch.searchBusLine(new BusLineSearchOption()
                                        .city(AppConstant.CityName)
                                        .uid(poiInfo.uid));
                                break;
                            }
                        }
                        if (count == 0) {
                            cancelLoadingDialog();
                            toast("未找到结果");
                        }
                    }
                }

                @Override
                public void onGetPoiDetailResult(PoiDetailResult poiDetailResult) {
                }
            };

    /**
     * 线路搜索
     */
    protected OnGetBusLineSearchResultListener onGetBusLineSearchResultListener =
            new OnGetBusLineSearchResultListener() {
                @Override
                public void onGetBusLineResult(BusLineResult busLineResult) {
                    cancelLoadingDialog();
                    if (busLineResult == null ||
                            busLineResult.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
                        toast("未找到结果");
                        return;
                    }
                    if (busLineResult.error == SearchResult.ERRORNO.NO_ERROR) {
                        mapStatusChangeTag = 5;
                        saleRegionLevelOverlay.removeFromMap();
                        esfMainMapOverlay.removeFromMap();
                        railwayLineOverlay.setData(busLineResult);
                        railwayLineOverlay.addToMap();
                        if (TextUtils.isEmpty(stationName)) {
                            baiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngZoom(cityCenter, 14f));
                        } else {
                            baiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngZoom(cityCenter, 16f));
                        }
                    }
                }
            };

    @Override
    protected void initView() {
        postListApi = new PostListApi(getClass(), PostListRo.class, new IResponseListener<PostListRo>() {
            @Override
            public void onResponse(PostListRo postListRo) {
                postMapCallback.callBack(getPostType(), postListRo.getList());
            }

            @Override
            public void onErrorResponse(VolleyError error) {
                responseError();
            }
        });
        postListApi.setPostType(getPostType());
        regionPosts3Api = new RegionPosts3Api(getClass(), RegionPostRo.class, new IResponseListener<RegionPostRo>() {
            @Override
            public void onResponse(RegionPostRo regionPostRo) {
                cancelLoadingDialog();
                if (regionPostRo != null &&
                        regionPostRo.getList() != null) {
                    regionList.clear();
                    gscopList.clear();
                    for (RegionPostBo regionPostBo : regionPostRo.getList()) {
                        if (regionPostBo.getGScopeLevel() == 2) {//区域
                            regionList.add(regionPostBo);
                        } else {
                            gscopList.add(regionPostBo);
                        }
                    }
                    updateMap(true);
                } else {
                    toast("未找到结果");
                    saleRegionLevelOverlay.removeFromMap();
                    esfMainMapOverlay.removeFromMap();
                    railwayLineOverlay.removeFromMap();
                }
            }

            @Override
            public void onErrorResponse(VolleyError error) {
                cancelLoadingDialog();
                toast("未找到结果");
                saleRegionLevelOverlay.removeFromMap();
                esfMainMapOverlay.removeFromMap();
                railwayLineOverlay.removeFromMap();
            }
        });
        regionPosts3Api.setPostType(getPostType());
        esfMapApi = new EsfMapApi(getClass(), EsfEstateListRo.class,
                new IResponseListener<EsfEstateListRo>() {
                    @Override
                    public void onResponse(EsfEstateListRo esfEstateListRo) {
                        cancelLoadingDialog();
                        esfEstateDos.clear();
                        if (esfEstateListRo.getList() != null) {
                            esfEstateDos.addAll(esfEstateListRo.getList());
                        }
                        saleRegionLevelOverlay.removeFromMap();
                        esfMainMapOverlay.mapStatusChangeAndClear();
                    }

                    @Override
                    public void onErrorResponse(VolleyError error) {
                        cancelLoadingDialog();
                        toast("未找到结果");
                        saleRegionLevelOverlay.removeFromMap();
                        esfMainMapOverlay.removeFromMap();
                        railwayLineOverlay.removeFromMap();
                    }
                });
        esfMapApi.setPostType(getPostType());

        poiSearch = PoiSearch.newInstance();
        poiSearch.setOnGetPoiSearchResultListener(onGetPoiSearchResultListener);
        busLineSearch = BusLineSearch.newInstance();
        busLineSearch.setOnGetBusLineSearchResultListener(onGetBusLineSearchResultListener);
        super.initView();
    }

    protected abstract String getPostType();

    protected abstract int dropArrayId();

    @Override
    protected void initDrop() {
        dropDownView.initTabs(dropArrayId());
    }

    @Override
    protected void initOther() {
        saleMainMapBo = new SaleMainMapBo(0, null);
        saleRegionLevelOverlay = new SaleRegionLevelOverlay(getActivity(), getPostType(), baiduMap, mapShowList,
                new BaiduMarkerClick() {
                    @Override
                    public boolean onMarkerClick(Marker marker) {//区域板块点击
                        if (marker != null) {
                            Bundle bundle = marker.getExtraInfo();
                            if (bundle != null) {
                                RegionPostBo regionPostBo = bundle.getParcelable(ExtraConstant.MAP_EXTRA_INFO);
                                if (regionPostBo != null) {
                                    if (regionPostBo.getGScopeLevel() == 2) {
                                        mapStatusChangeTag = 2;
                                        tempRegionId = String.valueOf(regionPostBo.getGScopeId());
                                        baiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngZoom(
                                                new LatLng(regionPostBo.getLat(), regionPostBo.getLng()), 14f));
                                    } else {
                                        mapStatusChangeTag = 3;
                                        baiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngZoom(
                                                new LatLng(regionPostBo.getLat(), regionPostBo.getLng()), 17f));
                                    }
                                }
                            }
                        }
                        return false;
                    }
                }
        );
        baiduMap.setOnMarkerClickListener(saleRegionLevelOverlay);

        esfMainMapOverlay = new EsfMainMapOverlay(getContext(), baiduMap, getPostType(), esfEstateDos,
                new BaiduMarkerClick() {
                    @Override
                    public boolean onMarkerClick(Marker marker) {
                        EsfEstateDo esfEstateDo = marker.getExtraInfo().getParcelable(ExtraConstant.MAP_EXTRA_INFO);
                        mapStatusChangeTag = 6;
                        if (esfEstateDo != null) {
                            postListApi.setEstCode(esfEstateDo.getCestCode());
                            postMapCallback.callBottomSheet(getPostType(), esfEstateDo);
                            if (baiduMap.getMapStatus().target == marker.getPosition()) {
                                updateMapStatusByBottomPop(false);
                            } else {
                                detailStatus = -1;
                                baiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLng(marker.getPosition()));
                            }
                            return true;
                        }
                        return false;
                    }
                });
        baiduMap.setOnMarkerClickListener(esfMainMapOverlay);

        railwayLineOverlay = new RailwayLineOverlay(getContext(), baiduMap);
        baiduMap.setOnMarkerClickListener(railwayLineOverlay);
    }

    /**
     * 更新地图
     */
    protected void updateMap(boolean reset) {
        if (endZoom < 14f) {//区域
            esfEstateDos.clear();
            esfMainMapOverlay.removeFromMap();
            if (reset || startZoom >= 14f) {
                mapShowList.clear();
                saleRegionLevelOverlay.removeFromMap();
                mapShowList.addAll(regionList);
                saleRegionLevelOverlay.mapStatusChange();
            }
            if (endZoom < 12f) {
                baiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngZoom(cityCenter, 12f));
            }
        } else if (endZoom < 15f) {//板块
            esfEstateDos.clear();
            esfMainMapOverlay.removeFromMap();
            if (reset || startZoom < 14f || startZoom >= 15f || mapShowList.size() != gscopList.size()) {
                mapShowList.clear();
                saleRegionLevelOverlay.removeFromMap();
                if (TextUtils.isEmpty(tempRegionId)) {
                    mapShowList.addAll(gscopList);
                } else {
                    for (RegionPostBo regionPostBo : gscopList) {
                        if (tempRegionId.equalsIgnoreCase(String.valueOf(regionPostBo.getParentId()))) {
                            mapShowList.add(regionPostBo);
                        }
                    }
                    tempRegionId = null;
                }
                saleRegionLevelOverlay.mapStatusChange();
            }
        } else {//小区层级
            LatLngBounds latLngBounds = baiduMap.getMapStatus().bound;
            saleRegionLevelOverlay.removeFromMap();
            if (reset || esfEstateDos.size() == 0) {
                //请求数据
                showLoadingDialog();
                requestEsfList(baiduMap.getMapStatus());
            } else {
                if (endMapStatus.bound.southwest.longitude > latLngBounds.southwest.longitude ||
                        endMapStatus.bound.southwest.latitude > latLngBounds.southwest.latitude ||
                        endMapStatus.bound.northeast.longitude < latLngBounds.northeast.longitude ||
                        endMapStatus.bound.northeast.latitude < latLngBounds.northeast.latitude) {
                    //请求数据
                    showLoadingDialog();
                    requestEsfList(baiduMap.getMapStatus());
                } else {
                    esfMainMapOverlay.mapStatusChange();
                }
            }
        }
    }

    @Override
    public void onMapStatusChangeFinish(MapStatus mapStatus) {
        super.onMapStatusChangeFinish(mapStatus);
        if (targetScreenY == 0) {
            targetScreenY = mapStatus.targetScreen.y;
        }
        switch (mapStatusChangeTag) {
            case 4://定位
                updateMap(!TextUtils.isEmpty(tempRegionId));
                break;
            case 5://地铁
                if (!TextUtils.isEmpty(stationName)) {
                    railwayLineOverlay.setStation(stationName);
                    stationName = null;
                }
                if (mapStatus.zoom > 16f) {
                    LatLngBounds latLngBounds = mapStatus.bound;
                    if (esfEstateDos.size() > 0) {
                        if (endMapStatus.bound.southwest.longitude > latLngBounds.southwest.longitude ||
                                endMapStatus.bound.southwest.latitude > latLngBounds.southwest.latitude ||
                                endMapStatus.bound.northeast.longitude < latLngBounds.northeast.longitude ||
                                endMapStatus.bound.northeast.latitude < latLngBounds.northeast.latitude) {
                            //请求数据
                            showLoadingDialog();
                            requestEsfList(baiduMap.getMapStatus());
                        } else {
                            esfMainMapOverlay.mapStatusChange();
                        }
                    } else {
                        //请求数据
                        showLoadingDialog();
                        requestEsfList(baiduMap.getMapStatus());
                    }
                } else {
                    esfMainMapOverlay.removeFromMap();
                }
                break;
            case 6://小区内房源
                switch (detailStatus) {
                    case -1:
                        updateMapStatusByBottomPop(false);
                        break;
                    case 1:
                        detailStatus = 0;
                        mapStatusChangeTag = -1;
                        break;
                    default:
                        break;
                }
                break;
            default:
                updateMap(!TextUtils.isEmpty(tempRegionId));
                break;
        }
        if (mapStatusChangeTag == 5 || mapStatusChangeTag == 6) {
            return;
        }
        mapStatusChangeTag = -1;
    }

    @Override
    protected void requestList(boolean needLocation) {
        requestRegionList();
    }

    /**
     * 请求区域板块
     */

    protected void requestRegionList() {
        showLoadingDialog();
        regionPosts3Api.startRequest();
    }

    /**
     * 请求小区列表
     */
    protected void requestEsfList(MapStatus mapStatus) {
        endMapStatus = mapStatus;
        esfMapApi.setSouthwest(mapStatus.bound.southwest);
        esfMapApi.setNortheast(mapStatus.bound.northeast);
        esfMapApi.startRequest();
    }

    @Override
    protected void locationInfo(BDLocation bdLocation) {
        switch (bdLocation.getLocType()) {
            case 61:
            case 161:
                mapStatusChangeTag = 4;
                float zoom = distance == 1000 ? 18f : distance == 1500 ? 17.8f : 17.5f;
                baiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngZoom(
                        new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude()), zoom));
                break;
            default:
                toast("定位失败");
                break;
        }
    }

    /**
     * 下拉
     */
    public void downRequest() {
        postListApi.setStartIndex(0);
        requestPostList();
    }

    /**
     * 上拉
     */
    public void upRequest(int count) {
        postListApi.setStartIndex(count);
        requestPostList();
    }

    /**
     * 隐藏
     */
    public void updateMapStatusByBottomPop(boolean reset) {
        if (reset) {
            detailStatus = 1;
            esfMainMapOverlay.removeSelect();
            baiduMap.animateMapStatus(MapStatusUpdateFactory.scrollBy(0,
                    -targetScreenY * 2 / 3), 150);
        } else {
            detailStatus = 0;
            baiduMap.animateMapStatus(MapStatusUpdateFactory.scrollBy(0,
                    targetScreenY * 2 / 3), 150);
        }
    }

    /**
     * 请求房源列表
     */
    protected void requestPostList() {
        postListApi.startRequest();
    }

    /**
     * 租售房源请求出错
     */
    protected void responseError() {

    }

}
